import { get, post } from '@/utils/http'

enum API {
  // 获取用户信息
  GETUSERINFO_API = '/user/getUserInfo',
  // 头像绑定账号
  BINDACCOUNT_API = '/user/bingAccount',
  // 修改姓名
  UPDATENAME_API = '/user/updateName',
  // 修改性别
  UPDATESEX_API = '/user/updateSex',
  // 修改邮箱
  UPDATEEMAIL_API = '/user/updateEmail',
  // 修改密码
  UPDATEPASSWORD_API = '/user/updatePasswordLogin'
}
// 获取用户信息
export const getUserInfoAPI = (id: number) => {
  return get<UserInfoData>(API.GETUSERINFO_API, { params: { id } })
}
// 头像绑定账号
export const bindAccountAPI = (account: number | null, onlyId: string, url: string) => {
  return post<void>(API.BINDACCOUNT_API, {
    account,
    onlyId,
    url
  })
}
// 修改姓名
export const updateNameAPI = (id: number, name: string) => {
  return post<void>(API.UPDATENAME_API, {
    id,
    name
  })
}
// 修改性别
export const updateSexAPI = (id: number, sex: string) => {
  return post<void>(API.UPDATESEX_API, {
    id,
    sex
  })
}
// 修改邮箱
export const updateEmailAPI = (id: number, email: string) => {
  return post<void>(API.UPDATEEMAIL_API, {
    id,
    email
  })
}
// 修改密码
export const updatePasswordAPI = (id: number, newPassword: string, oldPassword: string) => {
  return post<void>(API.UPDATEPASSWORD_API, {
    id,
    oldPassword,
    newPassword
  })
}
